/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hibernate.entidades;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ariel
 */
@Entity
@Table(name = "detalle_ped_prov")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DetallePedProv.findAll", query = "SELECT d FROM DetallePedProv d"),
    @NamedQuery(name = "DetallePedProv.findByCodPedProv", query = "SELECT d FROM DetallePedProv d WHERE d.detallePedProvPK.codPedProv = :codPedProv"),
    @NamedQuery(name = "DetallePedProv.findByLinea", query = "SELECT d FROM DetallePedProv d WHERE d.detallePedProvPK.linea = :linea"),
    @NamedQuery(name = "DetallePedProv.findByCantidad", query = "SELECT d FROM DetallePedProv d WHERE d.cantidad = :cantidad")})
public class DetallePedProv implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DetallePedProvPK detallePedProvPK;
    @Column(name = "cantidad")
    private Short cantidad;
    @JoinColumn(name = "cod_ped_prov", referencedColumnName = "cod_ped_prov", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private PedidoProveedor pedidoProveedor;
    @JoinColumn(name = "cod_stock", referencedColumnName = "cod_stock")
    @ManyToOne
    private Productos codStock;

    public DetallePedProv() {
    }

    public DetallePedProv(DetallePedProvPK detallePedProvPK) {
        this.detallePedProvPK = detallePedProvPK;
    }

    public DetallePedProv(String codPedProv, String linea) {
        this.detallePedProvPK = new DetallePedProvPK(codPedProv, linea);
    }

    public DetallePedProvPK getDetallePedProvPK() {
        return detallePedProvPK;
    }

    public void setDetallePedProvPK(DetallePedProvPK detallePedProvPK) {
        this.detallePedProvPK = detallePedProvPK;
    }

    public Short getCantidad() {
        return cantidad;
    }

    public void setCantidad(Short cantidad) {
        this.cantidad = cantidad;
    }

    public PedidoProveedor getPedidoProveedor() {
        return pedidoProveedor;
    }

    public void setPedidoProveedor(PedidoProveedor pedidoProveedor) {
        this.pedidoProveedor = pedidoProveedor;
    }

    public Productos getCodStock() {
        return codStock;
    }

    public void setCodStock(Productos codStock) {
        this.codStock = codStock;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (detallePedProvPK != null ? detallePedProvPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetallePedProv)) {
            return false;
        }
        DetallePedProv other = (DetallePedProv) object;
        if ((this.detallePedProvPK == null && other.detallePedProvPK != null) || (this.detallePedProvPK != null && !this.detallePedProvPK.equals(other.detallePedProvPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "hibernate.entidades.DetallePedProv[ detallePedProvPK=" + detallePedProvPK + " ]";
    }
    
}
